package org.apak.tests;



import junit.framework.TestCase;

import org.apak.control.ErrorList;
import org.apak.control.ServiceActionForm;
import org.apak.control.ServicePartForm;
import org.apak.control.Validator;

public class ValidatorTest extends TestCase {
	
	private ServiceActionForm serviceActionForm;
	private ServicePartForm servicePartForm;
	private Validator validator = new Validator();

	protected void setUp() {
		serviceActionForm = new ServiceActionForm("2", "type", "device", "8", "notvalidamount", "noprice", "");
		servicePartForm = new ServicePartForm("2", "", "device", "8", "", "");
	}
	
	public void testFindErrorsServiceActionForm() {
		ErrorList errors = validator.findErrors(serviceActionForm);
		assertEquals("Wrong price", errors.getError("price").trim());
		assertEquals("Wrong amount", errors.getError("service_amount").trim());
		assertEquals("Description cannot be empty", errors.getError("action_description").trim());
	}
	
	public void testFindErrorsServicePartForm() {
		ErrorList errors = validator.findErrors(servicePartForm);
		assertEquals("Wrong price", errors.getError("part_price").trim());
		assertEquals("Wrong amount", errors.getError("part_count").trim());
		assertEquals("Name cannot be empty", errors.getError("part_name").trim());
	}

}
